<?php
//dump($data);
?>
<!DOCTYPE html>
<html lang="zh-cn" style="font-size: 50px">
<head>
    <include file="Common/meta" />
    <title>注册 - {$_ENV['site'][0]['title']}</title>
    <include file="Common/link" />
</head>
<body>
<header class="layout-header">
    <div class="container">
        <h1 class="title">注册</h1>
        <a class="header-back" href="#"><i class="icon icon-left"></i></a>
    </div>
</header>
<div class="layout-body">
    <div class="container">
        <section class="box box-login">
            <div class="box-body">
                <form class="form-horizontal">
                    <input id="account" class="input" value="" placeholder="邮箱（作为用户名）">
                    <input id="password" class="input" value="" placeholder="密码" type="password" autocomplete="off">
                    <input id="password2" class="input" value="" placeholder="确认密码" type="password" autocomplete="off">
                    <input id="school" class="input" placeholder="学校" readonly>
                    <div class="group">
                        <input id="name" class="input input-name" placeholder="姓名">
                        <input id="school-id" class="input input-school-id" placeholder="学号">
                    </div>
                    <button id="register" class="btn-register" type="button">注册</button>
                </form>
                <footer>
                    <a class="go-login" href="/Page/login">已有账号？马上登陆</a>
                </footer>
            </div>

        </section>


    </div>
</div>
<!-- 学校选择框 -->
<div id="school-dialog" class="school-dialog">
    <input id="school-selector-search" class="input" placeholder="输入学校名称进行搜索">
    <ul id="school-selector-list" class="school-selector-list">
        <li><a href="#">广东工业大学</a> </li>
        <li><a href="#">广东工业大学</a> </li>
        <li><a href="#">广东工业大学</a> </li>
        <li><a href="#">广东工业大学</a> </li>
        <li><a href="#">广东工业大学</a> </li>
        <li><a href="#">广东工业大学</a> </li>
    </ul>
    <div id="school-selector-empty" class="school-selector-empty tc-hide">搜索不到学校</div>
</div>
<include file="Common/script" />
<script src="__PUBLIC__/asset/js/register.js"></script>
<script>
    $('#school').on('click', function () {
        /*$('#like-wrap').dialog({
            title: '选择学校'
        });*/
        eui.dialog({
            title: '选择学校',
            content: $('#school-dialog'),
            btn: false
        })
    });

    $('#school-selector-search').on('input', function () {
        var val = $(this).val();
        showSchool(val);
    });

    $('#school-selector-list').on('click', 'li a', function (e) {
        e.preventDefault();
        $('#school').val($(this).text());

        $('#like-wrap').dialog('hide');
    });

    showSchool();
    function showSchool(input) {
        $.ajax({
            url: '/common/schoolSearch',
            data: {
                key: input,
            },
            dataType: 'json',
            success: function (obj) {
                var list = obj.list;
                if (!list.length) {
                    $('#school-selector-list').hide();
                    $('#school-selector-empty').show();
                    return;
                }
                $('#school-selector-empty').hide();
                var $list = $('#school-selector-list');
                $list.show();
                $list.empty();
                var html = '';

                for (var i = 0; i < list.length; i++) {
                    html += '<li><a href="#">' + list[i].name + '</a></li>'
                }
                $list.html(html);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                eui.msg('系统出错');
            }
        });
    }
</script>
</body>
</html>

